﻿CREATE PROCEDURE [ProductFeedback].[GetProductRatingAttributeProductRelations]
	@TenantId uniqueidentifier,
	@CatalogId [ProductFeedback].[TCatalogId],
	@ProductId [ProductFeedback].[TProductId]
AS

-- 1st
SELECT
	PRAPA.AttributeId,
	PRAPA.StartDate,
	PRAPA.FinishDate,
	PRAPA.DisplayOrder
FROM
	ProductRatingAttributeProductAssociation PRAPA
	INNER JOIN ProductRatingAttribute PRA ON PRAPA.TenantId = PRA.TenantId AND PRAPA.AttributeId = PRA.AttributeId
WHERE
	PRAPA.ProductId = @ProductId
	AND PRA.TenantId = @TenantId

-- 2nd
SELECT
	PRAPD.AttributeId,
	PRAPD.StartDate,
	PRAPD.FinishDate
FROM
	ProductRatingAttributeProductDisassociation PRAPD
	INNER JOIN ProductRatingAttribute PRA ON PRAPD.TenantId = PRA.TenantId AND PRAPD.AttributeId = PRA.AttributeId
WHERE
	PRAPD.ProductId = @ProductId
	AND PRA.TenantId = @TenantId
